// pages/mine/wallet/index.js
const App = getApp()
import Kits from '../../../utils/kits'

Page({
  data: {
    init: false,

    summ: {
      couponStr: '--',
      amountStr: '--',
      settleStr: '--',
      depositStr: '--',
    }
  },
  onLoad() {
    wx.sub('ReloadUserFin', this, () => {
      this.execLoadFin()
    })
    this.execLoadFin()

  },
  onUnload(){
    wx.cancel('ReloadUserFin', this)

  },
  execLoadFin() {
    App.doPost({
      uri: '/app/wallet/fin/summary',
      body: {},
      fnSucc: resp => {
        resp.data.couponStr = (resp.data.coupon) + ''
        resp.data.amountStr = Kits.fmtMoneyString(resp.data.amount)
        resp.data.settleStr = Kits.fmtMoneyString(resp.data.settle)
        resp.data.depositStr = Kits.fmtMoneyString(resp.data.deposit)
        this.setData({
          init: true,
          summ: resp.data
        })
      }
    })
  },
  toPage(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.uri
    })
  },
})